from sklearn.cluster import DBSCAN


def run(df, params):
    df = df.dropna()

    eps = float(params["eps"])
    min_samples = int(params["min_samples"])
    metric = params["metric"]

    clustering = DBSCAN(eps=eps, min_samples=min_samples, metric=metric).fit(df[params["cols"]].values)
    pred = clustering.labels_

    output_cols = "_cluster_id_"
    df[output_cols] = pred.astype("int")

    return df
